<template>
  <van-config-provider :theme-vars="themeVars">
    <div class="login_container">

      <!-- 导航栏 -->
      <van-nav-bar class="login_top" title="网易严选">
        <template #left>
          <van-icon name="wap-home-o" size="32" color="#333" />
        </template>

        <template #right>
          <van-icon name="search" class="login_search" size="32" color="#333" />
          <van-icon name="shopping-cart-o" size="32" color="#333" />
        </template>
      </van-nav-bar>

      <!-- 根1 -->
      <div class="login_type">
        <!-- 下内容根组件 -->
        <div class="login_body">
          <!-- 图片 + 双登录 -->
          <div class="login_item">
            <!-- 中间logo图片 -->
            <div class="login_item_img">
              <van-image width="148" height="50" fit="contain" position="bottom"
                src="	https://yanxuan.nosdn.127.net/static-union/164793255107785e.png" />
            </div>
          </div>

          <!-- 输入验证 -->
          <div class="body_verify">

            <!-- 手机 -->
            <div class="phone_verify">
              <van-field v-model="loginFrom.phone" type="tel" placeholder="手机号" :required="true"  />
            </div>

            <!-- 密码 -->
            <div class="email_verify">
              <van-field v-model="loginFrom.password" type="password" placeholder="密码" :required="true" />
            </div>
          </div>


          <!-- 遇到问题和验证登录 -->
          <div class="options">
            <span>忘记密码?</span>
            <van-button type="default" size="small" :to="{path: '/loginWithPhone'}">短信验证快捷登录</van-button>
          </div>


          <!-- 登录 -->
            <div class="loginButton">
              <van-button 
                class="button_phone" 
                type="danger" 
                size="large" 
                native-type="submit" 
                @click="getLogin"
              >登录</van-button>
          </div>

          <!-- 其他登录方式 -->
          <div class="otherOptions">
            <van-button type="default" size="small" to="Login">其他登录方式</van-button>
          </div>


        </div>
      </div>



    </div>
  </van-config-provider>
</template>

<script lang="ts">
  export default {
    name: 'Password',
  }
</script>


<script lang="ts" setup>
import { useRouter } from 'vue-router';
import { ref, reactive, createApp, onMounted } from 'vue';
import { Image as VanImage, Col, Row, Button, } from 'vant'
import userInfo from '@/store/userInfo';

// 变量
const router = useRouter()
const userInfoToken = userInfo()


const loginFrom = ref({
  phone: '13700000000',
  password: '111111'
})


// 生命周期

// 回调

// 点击登录的回调
// const getLogin = () => {
//   userInfoToken.login(loginFrom.value.phone,loginFrom.value.password )
// }

const getLogin = async () => {
  try {
    userInfoToken.login(loginFrom.value.phone,loginFrom.value.password )
    // 跳转到主页
    router.push({ path: '/' })
  } catch (error) {}
}

const themeVars = reactive({
  // 输入框内字体
  fieldPlaceholderTextColor: '#7F7F7F',
  // button 边框颜色
  buttonDefaultBorderColor: '#FFFFFF'
});
</script>

<style scoped>
/* 导航 */
.login_top {
  background: #fafafa
}

/* 根1 */
.login_type {
  height: 688px;
  display: block;

}

/* 根2 */
.login_body {
  height: 100%;
  background: #fff;
  position: relative;
}

/* 搜索向右扩展 */
.login_search {
  margin-right: 14px;
}

/* 图片 */
.login_item_img {
  text-align: center;
  padding-top: 24px;
  margin-bottom: 40px;
}

/* 验证样式 */
.body_verify div input {
  border: none;
  border-bottom: 1px solid #d1cdcd98;
  font-size: 14px;
  width: 330px;
  height: 30px;
  margin-top: 20px;
}

/* 手机号样式 */
.phone_verify {
  padding-left: 20px;
}

/* 验证码样式 */
.email_verify {
  padding-left: 20px;
  margin-top: 10px;
}

/* 短信验证样式 */


/* 遇到问题验证登录 */
.options {
  width: 330px;
  position: absolute;
  left: 50%;
  top: 40%;
  font-size: 14px;
  color: #524e4ec3;
  transform: translate(-50%, -50%);
}

/* 验证登录 */
.options :nth-child(2) {
  margin-left: 150px;
  color: #333333;
}

/* 按钮 */
.loginButton {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 330px;
}

/* 其他登录方式 */
.otherOptions {
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translate(-50%, -50%);
  width: 100px;
  font-size: 14px;
}

</style>
